<?php
session_start();

//Idioma por Default
if(!isset($_SESSION['Idioma']) || !empty($_REQUEST['selLanguage'])) {
	if(!empty($_REQUEST['selLanguage']))
		$_SESSION['Idioma'] = $_REQUEST['selLanguage'];
	else
		$_SESSION['Idioma'] = 'es';
}

require("includes/funciones.inc.php");
require("includes/selectLanguage.php");
require("includes/constants.php");

$DB = NewADOConnection('mysqlt');
$DB->Connect();
$DB->Execute("SET NAMES utf8;");
//$DB->debug=true;

//LOGIN
if(!empty($_POST['txtUser']))
{
	$mcrypt = new MCrypt();
	$encryptedPass = $mcrypt->encrypt($_REQUEST["txtPass"]);
			
	$strSQL = "SELECT * FROM users WHERE userName = '".$_REQUEST['txtUser']."' AND userPassword = '".$encryptedPass."'";
	
	$rsUser = $DB->Execute($strSQL); 
	if (!$rsUser->EOF)
	{
		$_SESSION['idUser'] = $rsUser->fields("idUser");
		$_SESSION['userName'] = $rsUser->fields("userName");
		$_SESSION['userCompleteName'] = $rsUser->fields("userCompleteName");
		$_SESSION['userType'] = $rsUser->fields("idTypeUser");
		$_SESSION['userRestaurant'] = $rsUser->fields("idRestaurant");
			
		Header("Location: main.php");
		exit();
	}
}

if($_SESSION['Idioma'] == 'es') {
	$imgES = 'es.png';
	$imgEN = 'en_off.png';
	$imgPO = 'po_off.png';
	$slanguage = 'es';
}
else if ($_SESSION['Idioma'] == 'en') {
	$imgES = 'es_off.png';
	$imgEN = 'en.png';
	$imgPO = 'po_off.png';
	$slanguage = 'en';
}
else if ($_SESSION['Idioma'] == 'po') {
	$imgES = 'es_off.png';
	$imgEN = 'en_off.png';
	$imgPO = 'po.png';
	$slanguage = 'po';
}

?>
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html" />
		<link href="js/datatables/themes/smoothness/jquery-ui-1.8.4.custom.css" media="screen" rel="stylesheet" type="text/css" />
		<link href="css/css.css" media="screen" rel="stylesheet" type="text/css" />
		<link href="css/scrollbar.css" media="screen" rel="stylesheet" type="text/css" />
		<link href='http://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
		<title>-:: RestoApp ::-</title>
		<!-- General Scripts -->
		<script type="text/javascript" src="js/jquery/jquery-1.7.1.min.js"></script>
		<script type="text/javascript" src="js/jquery/jquery-ui-1.8.16.custom.min.js"></script>
		<script type="text/javascript" src="js/jquery/jquery.ui.core.js"></script>
		<script type="text/javascript" src="js/jquery/jquery.ui.draggable.js"></script>
		<script type="text/javascript" src="js/jquery/jquery.ui.dialog.js"></script>
		<script type="text/javascript" src="js/jquery/jquery.mousewheel.js"></script>
		<script type="text/javascript" src="js/jquery/jquery.cycle.all.js"></script>
		<script type="text/javascript" src="js/jquery/jquery.scroll.js"></script>
		
		<!-- Form Script -->
		<script type="text/javascript" src="js/datatables/js/jquery.dataTables.min.js"></script>
		<script type="text/javascript" src="js/utils.js"></script>
		<script type="text/javascript" src="js/login.js"></script>
	</head>
	
	<body id="bodyLog">
		<img src="imagenes/logo.png" id="logoLog"/>
		<div class="slide_titulos" >
			<div class="titulos_"><?=$a_languages["Web.Buttons.RestoApp"];?></div>
			<div class="titulos_"><?=$a_languages["Web.Buttons.Product"];?></div>
			<div class="titulos_"><?=$a_languages["Web.Buttons.Enter"];?></div>
			<div class="titulos_"><?=$a_languages["Web.Buttons.Contact"];?></div>
			<div class="titulos_"><?=$a_languages["Web.Buttons.Demo"];?></div>
		</div>
		<div id="barra">
			<div class="slide_contenido">
				<div id="cajLog">
					<p>
						<?=$a_languages["Web.Section.RestoApp"];?>
					</p>
					<div class="circuito1"></div>
				</div>
				<div id="cajLog" class="scrollbar simple">
					<h2><?=$a_languages["Web.Product.Title"];?></h2>
					<ul>
						<li><?=$a_languages["Web.Product.Advantage1"];?></li>
						<li><?=$a_languages["Web.Product.Advantage2"];?></li>
						<li><?=$a_languages["Web.Product.Advantage3"];?></li>
						<li><?=$a_languages["Web.Product.Advantage4"];?></li>
						<li><?=$a_languages["Web.Product.Advantage5"];?></li>
						<li><?=$a_languages["Web.Product.Advantage6"];?></li>
						<li><?=$a_languages["Web.Product.Advantage7"];?></li>
						<li><?=$a_languages["Web.Product.Advantage8"];?></li>
						<li><?=$a_languages["Web.Product.Advantage9"];?></li>
						<li><?=$a_languages["Web.Product.Advantage10"];?></li>
						<li><?=$a_languages["Web.Product.Advantage11"];?></li>
						<li><?=$a_languages["Web.Product.Advantage12"];?></li>
						<li><?=$a_languages["Web.Product.Advantage13"];?></li>
						<li><?=$a_languages["Web.Product.Advantage14"];?></li>
						<li><?=$a_languages["Web.Product.Advantage15"];?></li>
						<li><?=$a_languages["Web.Product.Advantage16"];?></li>
						<li><?=$a_languages["Web.Product.Advantage17"];?></li>
						<li><?=$a_languages["Web.Product.Advantage18"];?></li>
						<li><?=$a_languages["Web.Product.Advantage19"];?></li>
						<li><?=$a_languages["Web.Product.Advantage20"];?></li>
						<li><?=$a_languages["Web.Product.Advantage21"];?></li>
						<li><?=$a_languages["Web.Product.Advantage22"];?></li>
						<li><?=$a_languages["Web.Product.Advantage23"];?></li>
						<li><?=$a_languages["Web.Product.Advantage24"];?></li>
					</ul>
					<div class="screen1"></div>
				</div>
				<div id="cajLog">
					<form id="frmLogin" name="frmLogin" method="post" action="" onsubmit="return $_validateFieldsMandatoriesForm();">			
						<table class="logTop" cellpadding="5px" cellspacing="5px">
							<tr>
								<td><img src="imagenes/usu.png" align="left"/></td>
								<td><input type="text" class="inputLog" name="txtUser" id="txtUser"></td>
								<td></td>
							</tr>
							<tr>
								<td><img src="imagenes/pass.png" align="left"/></td>
								<td><input type="password" class="inputLog" name="txtPass" id="txtPass"></td>
								<td></td>
							</tr>
							<tr>
								<td colspan="3"><a href="javascript:;" onclick="$_proxyShowOlvidoPass()"><span id="olvCont" class="detLog"><?=$a_languages["Web.Login.LostPassword"];?></span></a></td>
							</tr>
							<tr>
								<td colspan="3"><a href="javascript:;" onclick="$('#frmLogin').submit();" class="btnIncSes"><?=$a_languages["Login.lblInitSession"];?></a></td>
							</tr>
						</table>
					</form>
				</div>
				<div id="cajLog">
					<form id="frmContacto" name="frmContacto" method="post" action=""  onsubmit="return false;">
						<table>
							<tbody>
								<tr>
									<td class="celda_log"><?=$a_languages["Web.Contact.CompleteName"];?></td>
									<td><input name="frmContacto_Name" id="frmContacto_Name" class="inputContacto" type="text"></td>
								</tr>
								<tr>
									<td class="celda_log"><?=$a_languages["Web.Contact.Enterprise"];?></td>
									<td><input name="frmContacto_Resto" id="frmContacto_Resto" class="inputContacto" type="text"></td>
								</tr>
								<tr>
									<td class="celda_log"><?=$a_languages["Web.Contact.EMail"];?></td>
									<td><input name="frmContacto_EMail" id="frmContacto_EMail" class="inputContacto" type="text"></td>
								</tr>
								<tr>
									<td class="celda_log"><?=$a_languages["Web.Contact.Phone"];?></td>
									<td><input name="frmContacto_Phone" id="frmContacto_Phone" class="inputContacto" type="text"></td>
								</tr>
								<tr>
									<td class="celda_log"><?=$a_languages["Web.Contact.Message"];?></td>
									<td><textarea name="frmContacto_Message" id="frmContacto_Message" class="mensajeContacto"></textarea></td>
								</tr>
								<tr>
									<td></td>
									<td>
										<a class="btnMenu" id="frmContacto_butEMail"href="javascript:;" onclick="$_sendMailContact();"><?=$a_languages["Web.Contact.Send"];?></a>
										<img src="imagenes/init-loader.gif" id="initLoaderContacto" name="initLoaderContacto"/>
									</td>
								</tr>
							</tbody>
						</table>
					</form>
				</div>
				<div id="cajLog">
					<p style="margin-left: 25px;">
						<?=$a_languages["Web.Demo.Title"];?>
					</p>
					<form id="frmDemo" name="frmDemo" method="post" action="" onsubmit="return false;">
						<table>
							<tbody>
								<tr>
									<td class="celda_log"><?=$a_languages["Web.Demo.CompleteName"];?></td>
									<td><input name="frmDemo_Name" id="frmDemo_Name" class="inputContacto" type="text"></td>
								</tr>
								<tr>
									<td class="celda_log"><?=$a_languages["Web.Demo.Enterprise"];?></td>
									<td><input name="frmDemo_Resto" id="frmDemo_Resto" class="inputContacto" type="text"></td>
								</tr>
								<tr>
									<td class="celda_log"><?=$a_languages["Web.Demo.EMail"];?></td>
									<td><input name="frmDemo_EMail" id="frmDemo_EMail" class="inputContacto" type="text"></td>
								</tr>
								<tr>
									<td class="celda_log"><?=$a_languages["Web.Demo.Phone"];?></td>
									<td><input name="frmDemo_Phone" id="frmDemo_Phone" class="inputContacto" type="text"></td>
								</tr>
								<tr>
									<td></td>
									<td>
										<a class="btnMenu" id="frmDemo_butEMail" href="javascript:;" onclick="$_sendMailDemo();"><?=$a_languages["Web.Demo.Send"];?></a>
										<img src="imagenes/init-loader.gif" id="initLoaderDemo" name="initLoader"/>
									</td>
								</tr>
							</tbody>
						</table>
					</form>
				</div>
			</div>
			<div id="lang" style="margin-top: 3px;">
				<form id="frmWebPage" method="post" action="">
					<input type="hidden" id="selLanguage" name="selLanguage" value="<?=$slanguage?>" />
					<a href="javascript:;" onclick="$_changeLanguage('es')" style="margin-left:5px;"><img src="imagenes/language/<?=$imgES?>" border="none" /></a>
					<a href="javascript:;" onclick="$_changeLanguage('en')" style="margin-left:5px;"><img src="imagenes/language/<?=$imgEN?>" border="none" /></a>
					<a href="javascript:;" onclick="$_changeLanguage('po')" style="margin-left:5px;"><img src="imagenes/language/<?=$imgPO?>" border="none" /></a>
				</form>
			</div>
		</div>
		<div id="barra_botones">
			<ul id="navlist">
				<li><span id="restoApp" onclick="$_showMenu($(this));" class="btnBarraIndex"><?=$a_languages["Web.Buttons.RestoApp"];?></span></li>
				<li><span id="producto" onclick="$_showMenu($(this));" class="btnBarraIndex"><?=$a_languages["Web.Buttons.Product"];?></span></li>
				<li><span id="ingresar" onclick="$_showMenu($(this));" class="btnBarraIndex"><?=$a_languages["Web.Buttons.Enter"];?></span></li>
				<li><span id="contacto" onclick="$_showMenu($(this));" class="btnBarraIndex"><?=$a_languages["Web.Buttons.Contact"];?></span></li>
				<li><span id="demo" onclick="$_showMenu($(this));" class="btnBarraIndex"><?=$a_languages["Web.Buttons.Demo"];?></span></li>
			</ul>
		</div>
			
		<!-- PopUp Lost Password Dialog -->
		<div id="lostPassDialog"></div>
	</body>
	
	<!-- Global Message -->
	<div id="globalMess"> 
		<div class="img"></div>
		<div id="globalMessImgClose" class="imgClose"></div>
		<div id="tituloMess" class="msgTitulo">TITULO</div>
		<p id="textoMess" class="msgTexto">MENSAJE</p>
	</div>
	
</html>

<script type='text/javascript'>
	$(document).ready(
		function() {
					$("#initLoaderContacto").hide();
					$("#initLoaderDemo").hide();
					$('.scrollbar').scrollbar();
					$('.slide_contenido').cycle({fx: 'scrollLeft', timeout: 0});
					$('.slide_titulos').cycle({fx: 'scrollLeft',timeout: 0});
					$("body").css("overflow", "hidden");
					setTimeout(function(){focus_login()}, 100);
					<?php if (!empty($_POST['txtUser']) && $rsUser->EOF) { ?>
						$_showMessage('ERR', 'ERROR', '<?=$a_languages["Login.lblMenError"];?>');
						$_showMenu($('#ingresar'))
					<?php } ?>
					
					$("#lostPassDialog").dialog({
						autoOpen:false, 
						height:265, 
						width:500, 
						dialogClass:'no-close',
						beforeClose: function() {$("#lostPassDialog").empty();},
						open: function() {
							$('#lostPassDialog').css('background','url(imagenes/bg.gif)');
						}
					});
	});	
	var _gaq = _gaq || [];
  	_gaq.push(['_setAccount', 'UA-35019459-1']);
  	_gaq.push(['_trackPageview']);

  	(function() {
    	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  	})();
</script>